package com.wordsay.entity;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.wordsay.analyer.impl.PersonSimilarAnayler;
import com.wordsay.util.SimilarUtil;

public class PersonSimilarResult extends AnalystResult {

	private String personA;
	private String personB;

	private double similarRate;
	private List<HotItem> vectorA;
	private List<HotItem> vectorB;
	private double similarWordRate;
	
	
	public PersonSimilarResult(String personA,String personB){
		
		this.personA = personA;
		this.personB = personB;
		vectorA = new ArrayList<HotItem>();
		vectorB = new ArrayList<HotItem>();

	}

	
	public PersonSimilarResult(){}
	

	public List<HotItem> getVectorA() {
		return vectorA;
	}


	public void setVectorA(List<HotItem> vectorA) {
		this.vectorA = vectorA;
	}


	public List<HotItem> getVectorB() {
		return vectorB;
	}


	public void setVectorB(List<HotItem> vectorB) {
		this.vectorB = vectorB;
	}


	public String getPersonA() {
		return personA;
	}
	public void setPersonA(String personA) {
		this.personA = personA;
	}
	public String getPersonB() {
		return personB;
	}
	public void setPersonB(String personB) {
		this.personB = personB;
	}
	
	public double getSimilarRate() {
		return similarRate;
	}


	public void setSimilarRate(double similarRate) {
		this.similarRate = similarRate;
	}


	public void printResult() throws Exception{
		
		System.out.println("Person Similar: "+this.personA+" 和 "+this.personB);
		System.out.println("相似度:"+this.similarRate+"   描述:"+SimilarUtil.getSimilarDesc(this.similarRate, similarWordRate));
		System.out.println("相似词比例:"+(this.similarWordRate*100)+"%");
		System.out.println("在双方高频词汇中，相似词汇高频权值详细信息:");
		for(int i = 0; i < vectorA.size();i++){System.out.println("词组："+vectorA.get(i).getName()+" 在"+personA+"的权重:"+vectorA.get(i).getHotRate().doubleValue()+"  在"+personB+"的权重:"+vectorB.get(i).getHotRate().doubleValue());}
	}

	public boolean equals(Object obj){
	
		PersonSimilarResult analyer = (PersonSimilarResult)obj;
	      
		  if(analyer.getPersonA() == null || analyer.getPersonB() == null || this.personA == null || this.personB == null){
			  return false;
		  }
		
	      if((analyer.personA.trim().equals(this.personA.trim()) && 
	    		  analyer.personB.trim().equals(this.personB.trim())) ||
	    		  
	    		  (analyer.personA.trim().equals(this.personB.trim()) && 
	    	    		  analyer.personB.trim().equals(this.personA.trim()))
	    	    		  )
	    		  {
	    	  
	    	  return true;
	       }
	      
	      return false;
	}


	public double getSimilarWordRate() {
		return similarWordRate;
	}


	public void setSimilarWordRate(double similarWordRate) {
		this.similarWordRate = similarWordRate;
	}

	
}
